from bs4 import BeautifulSoup


class HtmlUtil:

    # 封装一个解析html 的通用方法
    @classmethod
    def html_parser(cls, resp):
        html_content = resp.json().get("description").get("form")
        bs = BeautifulSoup(html_content, "html.parser")
        # 获取三方接口依赖的URL
        url = bs.form.get("action")
        # 定义存储参数的变量
        params = {}
        # 获取所有的input标签
        input_list = bs.find_all("input")
        # 遍历input标签
        for input in input_list:
            params[input.get("name")] = input.get("value")
        return url, params
